home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 8 / Power CD-ROM 8.iso / windows / winbatch / kidproof.wb_ < prev    next >
Text File  |  1994-09-15  |  5KB  |  179 lines

  1.  a1="Lets you load some programs that kids want to play with, and then by "
  2.  a2="running this script, it will hide ProgMan and any iconized programs. "
  3.  a3="When all initial windows have been closed, you will be prompted for a "
  4.  a4="password to continue.  When the correct password is entered, the "
  5.  a5="iconized windows will come back.  PS.  The password for now is TINCAN"
  6.  
  7.  a6=strcat(a1,a2,a3,a4,a5)
  8.  Message("KidProof",a6)
  9.  drop(a1,a2,a3,a4,a5,a6)
  10.  
  11.  ;<-----------------------snip-------------------------------------------->
  12.  
  13.  ;Are we already running?
  14.  if WinState("Program Manager")==@HIDDEN
  15.     Display(5,"Hmmm","KidProof already running"
  16.     exit
  17.  endif
  18.  
  19.  PswdMsg="Password is tincan"   ; <<<<<<<<<<<<<<<<Edit this line
  20.  Password="tincan"              ; <<<<<<<<<<<<<<<<Edit this line too
  21.  
  22.  ;Stay Running!!!   This function required batch file to have normal exit
  23.  IntControl(12,10,"Close all programs before shutting down Windows",0,0)  
  24.  
  25.  ; Now we get busy
  26.  ;Get currently installed taskmanager
  27.  ;debug(1)
  28.  OrigTask=IniReadPvt("boot","taskman.exe","taskman.exe","system.ini")
  29.  OrigTask=FileLocate(OrigTask)
  30.  
  31.  if OrigTask==""          ; Initiate disaster recovery (Kid pressed reset button, etc)
  32.     Display(3,"Disaster Recovery","In Progress")
  33.     OrigTask=IniReadPvt("KIDTOY","Origtm",strcat(DirWindows(0),"taskman.exe"),"WWW-PROD.INI" )
  34.     CopyTask2=IniReadPvt("KIDTOY","backuptm",strcat(DirWindows(0),"taskman.cp2"),"WWW-PROD.INI" )
  35.     if !FileExist(CopyTask2)
  36.        Message("Disaster Recovery","Task Manager missing.  Best Wishes")
  37.        exit
  38.     endif
  39.     FileCopy(CopyTask2,OrigTask,0)
  40.     Display(3,"Disaster Recovery","Complete")
  41.  endif
  42.  
  43.  ppp=FilePath(OrigTask)              ; Parse out file names
  44.  rrr=FileRoot(OrigTask)
  45.  eee=FileExtension(OrigTask)
  46.  CopyTask=strcat(ppp,rrr,".CPY")     ; Build working file name
  47.  CopyTask2=strcat(ppp,rrr,".CP2")    ; Build disaster recovery file name
  48.  
  49.  if !FileExist(CopyTask2)             ; Save info for future disasters
  50.       FileCopy(OrigTask,CopyTask2,0)  ; Permanent backup   for future disaster recovery
  51.       IniWritePvt("KIDTOY","Origtm",OrigTask,"WWW-PROD.INI")
  52.       IniWritePvt("KIDTOY","backuptm",CopyTask2,"WWW-PROD.INI")
  53.  endif
  54.  
  55.  ; Remove task manager
  56.  if FileExist(OrigTask)
  57.     FileMove(OrigTask,CopyTask,0)
  58.  endif
  59.  
  60.  
  61.  
  62.  ;Following code helps in debug
  63.  ;ErrorMode(@off)
  64.  ;WinTitle("Program Manager","")
  65.  ;ErrorMode(@cancel)
  66.  ;Iconize Progman and File manager (comment out for debug )
  67.  ErrorMode(@off)
  68.  WinIconize("Program Manager")
  69.  WinIconize("File manager")
  70.  ErrorMode(@CANCEL)
  71.    
  72.  ;Grab current Windows and hide iconized ones.
  73.  gosub SetupSplash
  74.  
  75.  while @TRUE
  76.      Delay(2)               ; Don't suck up all system resources continiously
  77.      a=WinGetActive()       ; Any active Windows ???
  78.      if a == "" then break  ; No?  We are done
  79.  endwhile
  80.  
  81.  :CANCEL 
  82.  while @TRUE
  83.     ; Get authorization
  84.     pswd=AskPassword(PswdMsg,"Enter Password") 
  85.     password=strlower(password)
  86.     pswd=strlower(pswd)
  87.     if pswd==password then break
  88.     Display(5,"Ooopsie","Bad Password")
  89.  endwhile
  90.  
  91.  ;Bring back Windows    
  92.  gosub UnSplash
  93.  
  94.  ;Restore Taskmanager
  95.  ;debug(1)
  96.  FileMove(CopyTask,OrigTask,0)
  97.  
  98.  
  99.  
  100.  exit
  101.  
  102.  
  103.  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  104.  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  105.  ;SetupSplash hides all iconic windows, remembers winstate
  106.  :setupsplash
  107.  OrigWindowList=WinItemize()   ;Get list of all open Windows
  108.  OrigWindowCount=ItemCount(OrigWindowList,@tab)
  109.  for i=1 to OrigWindowCount
  110.     a=ItemExtract(i,OrigWindowList,@tab)
  111.     b = WinState(a)
  112.     OrigWindowState%i% = b
  113.     ; Note we could hide the other windows here, but if the install
  114.     ; bombs kind of bad, it leaves the user in a lurch and they
  115.     ; got to reboot.  Bad news.  With icons they can always recover
  116.     ; by themselves.
  117.     if b==@ICON then WinHide(a)
  118.  next
  119.  
  120.  return
  121.  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122.  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  123.  ;UnSplash undoes Setup Splash
  124.  :UnSplash
  125.  ErrorMode(@off)
  126.  for i= OrigWindowCount to 1 by -1
  127.     a=ItemExtract(i,OrigWindowList,@tab)
  128.     ;Display(3,"Window",a)
  129.      switch OrigWindowState%i%
  130.         case @HIDDEN
  131.            break
  132.         case @NORMAL
  133.            WinShow(a)
  134.            break
  135.         case @ICON
  136.            WinShow(a)
  137.            break
  138.         case @ZOOMED
  139.            WinZoom(a)
  140.            break
  141.      end switch
  142.  next
  143.  ErrorMode(@cancel)
  144.  return;
  145.  
  146.  
  147.  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.